home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Misc / GMS / GMSDev / Includes / dpkernel / dpkernel.i < prev   
Encoding:
Text File  |  1997-11-20  |  9.4 KB  |  335 lines

  1.     IFND DPKERNEL_I
  2. DPKERNEL_I  SET  1
  3.  
  4. **
  5. **  $VER: dpkernel.i V0.9B
  6. **
  7. **  General include file for programs using the DPKernel.
  8. **
  9. **  (C) Copyright 1996-1997 DreamWorld Productions.
  10. **      All Rights Reserved.
  11. **
  12. **
  13.  
  14.     IFND    LIBRARIES_DPKERNEL_LIB_I
  15.     include    'modules/dpkernel_lib.i'
  16.     include    'modules/screens.i'
  17.     include    'modules/blitter.i'
  18.     include    'modules/sound.i'
  19.     ENDC
  20.  
  21.     IFND    SYSTEM_TYPES_I
  22.     include 'system/types.i'
  23.     ENDC
  24.  
  25.     IFND    SYSTEM_REGISTER_I
  26.     include    'system/register.i'
  27.     ENDC
  28.  
  29. ****************************************************************************
  30.  
  31. DPKVersion  =  0             ;Version for these includes.
  32. DPKRevision =  9             ;Revision for these includes.
  33.  
  34. SKIPENTRY   =  0             ;Used to skip to the next entry.
  35. ENDLIST     =  -1            ;Used to terminate a list.
  36. LISTEND     =  -1            ;Synonym for ENDLIST.
  37. TAGEND      =  0             ;Used to terminate a tag list.
  38. DEFAULT     =  0
  39.  
  40. TBYTE       =  0             ;Flags used for constructing tag lists.
  41. TLONG       =  (1<<31)
  42. TWORD       =  (1<<30)
  43. TAPTR       =  (1<<29)|TLONG
  44. TSTEPIN     =  (1<<28)
  45. TSTEPOUT    =  (1<<27)
  46. TTRIGGER    =  (1<<26)
  47.  
  48.   IFND    TAG_IGNORE
  49. TAG_IGNORE  =  1
  50. TAG_MORE    =  2
  51. TAG_SKIP    =  3
  52.   ENDC
  53.  
  54. JMP_AMIGA   =  0
  55.  
  56. GET_NOTRACK = $00010000 ;Disables tracking on an object.
  57.  
  58. ****************************************************************************
  59. * Header used in all objects.
  60.  
  61.     STRUCTURE    Head,0
  62.     WORD    HEAD_ID       ;Object Identifier, eg ID_PICTURE
  63.     WORD    HEAD_Version  ;Version of this object.
  64.     APTR    HEAD_Class    ;Pointer to relevant system object.
  65.     APTR    HEAD_Stats    ;Private.
  66.     LABEL    HEAD_SIZEOF
  67.  
  68.     STRUCTURE    Stats,0             ;This structure is completely private.
  69.     LONG    STATS_Key           ;Resource key.
  70.     APTR    STATS_ChildPrivate  ;Available for child objects.
  71.     LONG    STATS_Flags         ;General flags.
  72.  
  73. ST_LOCK    =    $00000001
  74.  
  75. ****************************************************************************
  76. * RawData object.
  77.  
  78. RAWVERSION   = 1
  79. TAGS_RAWDATA = ((ID_SPCTAGS<<16)|ID_RAWDATA)
  80.  
  81.   STRUCTURE    RD,HEAD_SIZEOF     ;Standard structure header.
  82.     LONG    RD_Size            ;Size of the data in bytes.
  83.     APTR    RD_Data            ;Pointer to the data.
  84.     BYTE    RD_AFlags          ;Private.
  85.     BYTE    RD_Pad             ;Private.
  86.     LABEL    RD_SIZEOF
  87.  
  88. ****************************************************************************
  89. * This macro will allow you to run a DPK program directly (ie no StartDPK),
  90. * and still retain compatibility on other platforms.  It will also set up
  91. * the self-destruct mechanism so that hitting left-amiga and delete will
  92. * destroy your task and leave the system 100% intact with all resources.
  93. *
  94. * Usage: STARTDPK
  95.  
  96.    STRUCTURE    dp1,0
  97.     LONG    DPK_ID
  98.     WORD    DPK_Version
  99.     WORD    DPK_DPKType
  100.     LONG    DPK_Start
  101.     APTR    DPK_DPKBase
  102.     APTR    DPK_Name
  103.     APTR    DPK_Author
  104.     APTR    DPK_Date
  105.     APTR    DPK_Copyright
  106.     APTR    DPK_Short
  107.     WORD    DPK_MinVersion
  108.     WORD    DPK_MinRevision
  109.     APTR    DPK_GVBase
  110.  
  111. STARTDPK MACRO
  112.     bra.s    StartAmigaDOS    ;Jump if running from AmigaDOS.
  113.  
  114.     dc.l    "PRGM"    ;ID Header.
  115.     dc.w    1    ;Version number.
  116.     dc.w    JMP_LVO    ;Type of jump table from DPK.
  117.     dc.l    StartDPKernel    ;Start of program.
  118. DPKBase    dc.l    0    ;DPKBase.
  119.     dc.l    ProgName    ;Name of the program.
  120.     dc.l    ProgAuthor    ;Who wrote the program.
  121.     dc.l    ProgDate    ;Date of compilation.
  122.     dc.l    ProgCopyright    ;Copyright details.
  123.     dc.l    ProgShort    ;Short description of program.
  124.     dc.w    DPKVersion    ;Minimum required DPKernel version.
  125.     dc.w    DPKRevision    ;Minimum required DPKernel revision.
  126. GVBase:    dc.l    0    ;Global variable base.
  127.  
  128. StartAmigaDOS:
  129.     MOVEM.L    D0-D7/A0-A6,-(SP)    ;SP = Save all registers.
  130.     move.l    ($4).w,a6    ;a6 = ExecBase
  131.     lea    DPKName(pc),a1    ;a1 = Library name.
  132.     moveq    #DPKVersion,d0    ;d0 = Version of these includes.
  133.     jsr    -552(a6)    ;>> = OpenLibrary()
  134.     move.l    d0,DPKBase    ;ma = Save base.
  135.     beq    ProgEnd    ;>> = Error, exit.
  136.     move.w    #1,DOS
  137.  
  138.     move.l    d0,a6    ;a6 = DPKBase.
  139.     lea    ProgExit(pc),a0    ;a0 = Pointer to SelfDestruct() cleanup.
  140.     move.l    a7,a1    ;a1 = Stack pointer.
  141.     CALL    InitDestruct    ;>> = Initialise the call.
  142.     bra.s    Launch
  143.  
  144. StartDPKernel:
  145.     MOVEM.L    D0-D7/A0-A6,-(SP)    ;SP = Save all registers.
  146. Launch:    move.l    DPKBase(pc),a6
  147.     moveq    #MOD_SCREENS,d0
  148.     sub.l    a0,a0
  149.     CALL    OpenModule
  150.     move.l    d0,SCRModule
  151.     beq.s    ProgExit
  152.     move.l    d0,a5
  153.     move.l    MOD_ModBase(a5),SCRBase
  154.  
  155.     moveq    #MOD_SOUND,d0
  156.     sub.l    a0,a0
  157.     CALL    OpenModule
  158.     move.l    d0,SNDModule
  159.     beq.s    ProgExit
  160.     move.l    d0,a5
  161.     move.l    MOD_ModBase(a5),SNDBase
  162.  
  163.     moveq    #MOD_BLITTER,d0
  164.     sub.l    a0,a0
  165.     CALL    OpenModule
  166.     move.l    d0,BLTModule
  167.     beq.s    ProgExit
  168.     move.l    d0,a5
  169.     move.l    MOD_ModBase(a5),BLTBase
  170.  
  171.     bsr.s    Start\@    ;>> = Start the program.
  172.     tst.l    d0    ;d0 = Check for error.
  173.     beq.s    ProgExit    ;>> = No errors, exit.
  174.     move.l    DPKBase(pc),a6
  175.     CALL    ErrCode    ;>> = Send the error code.
  176.  
  177. ProgExit:
  178.     move.l    DPKBase(pc),a6    ;a6 = DPKBase
  179.     move.l    SCRModule(pc),a0
  180.     CALL    Free
  181.     move.l    BLTModule(pc),a0
  182.     CALL    Free
  183.     move.l    SNDModule(pc),a0
  184.     CALL    Free
  185.  
  186.     tst.w    DOS
  187.     beq.s    ProgEnd
  188.     CALL    CloseDPK    ;>> = Close the kernel.
  189. ProgEnd    MOVEM.L    (SP)+,D0-D7/A0-A6    ;SP = Return registers.
  190.     moveq    #$00,d0    ;d0 = No errors.
  191.     rts
  192.  
  193.     IFNC    '\1',''
  194. .name    dc.b    "\1",0
  195.     even
  196.     ENDC
  197.  
  198. DOS:        dc.w  0
  199. SNDBase:    dc.l  0
  200. BLTBase:    dc.l  0
  201. SCRBase:    dc.l  0
  202. SNDModule:    dc.l  0
  203. BLTModule:    dc.l  0
  204. SCRModule:    dc.l  0
  205.  
  206. DPKName:    dc.b  "GMS:libs/dpkernel.library",0
  207.         even
  208. Start\@
  209.     ENDM
  210.  
  211. ******************************************************************************
  212. * This macro provides an easy way of sending a message to IceBreaker.
  213. * The DPKBase must be in register a6.
  214. *
  215. * Example:
  216. *
  217. *    MESSAGE    "Hello World."
  218.  
  219. MESSAGE    MACRO
  220.     MOVEM.L    A5/D7,-(SP)
  221.     moveq    #DBG_Message,d7
  222.     lea    .text\@(pc),a5
  223.     CALL    DebugMessage
  224.     bra.s    .cont\@
  225. .text\@    dc.b    \1,0
  226.     even
  227. .cont\@    MOVEM.L    (SP)+,A5/D7
  228.     ENDM
  229.  
  230. *****************************************************************************
  231. * Universal errorcodes returned by certain functions.  These are further
  232. * explained in the documentation.
  233.  
  234.  STRUCTURE Errors,0
  235.   BYTE  ERR_OK          ;Function went OK.
  236.   BYTE  ERR_NOMEM       ;Not enough memory available.
  237.   BYTE  ERR_NOPTR       ;A required address pointer is not present.
  238.   BYTE  ERR_INUSE       ;Previous allocations have not been freed.
  239.   BYTE  ERR_STRUCT      ;Structure version not supported/not found.
  240.   BYTE  ERR_FAILED      ;General/Miscellaneous failure.
  241.   BYTE  ERR_FILE        ;General file error, eg file not found, disk full etc.
  242.   BYTE  ERR_BADDATA     ;There is an error in the given data.
  243.   BYTE  ERR_SEARCH      ;An internal search was performed and it failed.
  244.   BYTE  ERR_SCRTYPE     ;Screen Type not recognised.
  245.   BYTE  ERR_MODULE      ;Trouble with initialising/using a system module.
  246.   BYTE  ERR_RASTCOMMAND ;Invalid raster command detected.
  247.   BYTE  ERR_RASTERLIST  ;Complete rasterlist failure.
  248.   BYTE  ERR_NORASTER    ;Expected rasterlist is missing from GS_Rasterlist.
  249.   BYTE  ERR_DISKFULL    ;Disk full error.
  250.   BYTE  ERR_FILEMISSING ;File not found.
  251.   BYTE  ERR_WRONGVER    ;Wrong version or version not supported.
  252.   BYTE  ERR_MONITOR     ;Monitor driver not found or cannot be used.
  253.   BYTE  ERR_UNPACK      ;Problem with unpacking of data.
  254.   BYTE  ERR_ARGS        ;Invalid arguments passed to function.
  255.   BYTE  ERR_NODATA      ;No data is available for use.
  256.   BYTE  ERR_READ        ;Error reading data from file.
  257.   BYTE  ERR_WRITE       ;Error writing data to file.
  258.   BYTE  ERR_LOCK        ;Could not obtain lock on object.
  259.   BYTE  ERR_EXAMINE     ;Could not examine the directory or file.
  260.   BYTE  ERR_LOSTCLASS   ;This object has lost its class reference.
  261.   BYTE  ERR_NOACTION    ;This object does not support the required action.
  262.   BYTE  ERR_NOSUPPORT   ;Object does not support the given data.
  263.   BYTE  ERR_MEMORY      ;General memory error.
  264.   LABEL ERR_END         ;Private code (used by IceBreaker).
  265.  
  266. ERR_SUCCESS = ERR_OK       ;Synonym for ERR_OK.
  267. ERR_DATA =    ERR_BADDATA  ;Synonym for ERR_BADDATA.
  268.  
  269. *****************************************************************************
  270. * Memory types used by AllocMemBlock().  This is almost identical to the
  271. * exec definition but CHIP is renamed to VIDEO (displayable memory) and
  272. * there is an addition of BLIT and SOUND specific memory.  CLEARed memory is
  273. * redundant (all GMS memory is cleared on allocation), REVERSE and NO_EXPUNGE
  274. * are also no longer needed (NB: GMS uses exec's reverse flag to reduce
  275. * fragmentation).
  276.  
  277. MEM_DATA      = $00000000   ;Default.
  278. MEM_PRIVATE   = $00000001   ;Memory is for private use.
  279. MEM_VIDEO     = $00000002   ;Suitable for the video display and blitting.
  280. MEM_BLIT      = $00000004   ;For blitting only.
  281. MEM_SOUND     = $00000008   ;Sound/Audio memory for playback of sounds.
  282. MEM_CODE      = $00000010   ;For executing code and storing data.
  283. MEM_UNTRACKED = $80000000   ;Do not track the memory.
  284.  
  285. MPRIVATE      = MEM_PRIVATE ;Synonym.
  286.  
  287. MEMB_PRIVATE   = 0          ;Public access memory.
  288. MEMB_VIDEO     = 1          ;Displayable memory, blitter compatible.
  289. MEMB_BLIT      = 2          ;Blitter memory.
  290. MEMB_SOUND     = 3          ;Sound memory.
  291. MEMB_CODE      = 4          ;Code and data memory.
  292. MEMB_UNTRACKED = 31         ;Do not track the memory.
  293.  
  294.     ;IFND    SYSTEM_DPKBASE_I
  295.     ;include    'system/dpkbase.i'
  296.     ;ENDC
  297.  
  298.     IFND    SYSTEM_MODULES_I
  299.     include    'system/modules.i'
  300.     ENDC
  301.  
  302.     IFND    GRAPHICS_BLITTER_I
  303.     include    'graphics/blitter.i'
  304.     ENDC
  305.  
  306.     IFND    GRAPHICS_SCREENS_I
  307.     include    'graphics/screens.i'
  308.     ENDC
  309.  
  310.     IFND    GRAPHICS_PICTURES_I
  311.     include 'graphics/pictures.i'
  312.     ENDC
  313.  
  314.     IFND    SYSTEM_MISC_I
  315.     include 'system/misc.i'
  316.     ENDC
  317.  
  318.     IFND    SOUND_SOUND_I
  319.     include 'sound/sound.i'
  320.     ENDC
  321.  
  322.     IFND    INPUT_JOYPORTS_I
  323.     include 'input/joyports.i'
  324.     ENDC
  325.  
  326.     IFND    INPUT_KEYBOARD_I
  327.     include 'input/keyboard.i'
  328.     ENDC
  329.  
  330.     IFND    FILES_FILES_I
  331.     include 'files/files.i'
  332.     ENDC
  333.  
  334.   ENDC    ;DPKERNEL_I
  335.